package com.powernode.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

/**
 * @Description TODO 跨域处理类
 * @Date 2022/3/27 22:13
 * @Version 1.0
 */
@Configuration
public class AdminConfig {
//    @Bean
//    public CorsFilter corsFilter() {
//         UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
//        final CorsConfiguration configuration = new CorsConfiguration();
//        /*是否允许请求带有验证信息*/
//        configuration.setAllowCredentials(true);
//        /*允许访问的客户端域名*/
//        configuration.addAllowedOrigin("*");
//        /*允许服务端访问的客户端请求头*/
//        configuration.addAllowedHeader("*");
//        /*允许访问的方法名,GET POST等*/
//        configuration.addAllowedMethod("*");
//        source.registerCorsConfiguration("/**", configuration);
//        return new CorsFilter(source);
//    }

    @Bean
    BCryptPasswordEncoder getPasswordEncoder(){
        return new BCryptPasswordEncoder();
    }
}
